package com.edgclub.edg.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.edgclub.edg.R;
import com.edgclub.edg.model.TopicChannel;

import java.util.ArrayList;
import java.util.List;

public class ChannelsSeleteAdapter extends BaseAdapter {

	private Context mContext;

	private ArrayList<TopicChannel> topicChannels;

	public ChannelsSeleteAdapter(Context mContext) {
		this.mContext = mContext;
		

	}

	public void setTopicChannels(ArrayList<TopicChannel> topicChannels) {
		this.topicChannels = topicChannels;
	}

	@Override
	public int getCount() {
		if (null != topicChannels) {
			return topicChannels.size();
		}
		return 0;
	}

	@Override
	public Object getItem(int psoition) {
		if (null != topicChannels) {
			return topicChannels.get(psoition);
		}
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView,
			ViewGroup viewGroup) {
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.item_gz_channel_selete, null);
			holder = new ViewHolder();
			holder.channel_name = (TextView) convertView
					.findViewById(R.id.channel_name);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		TopicChannel channel = topicChannels.get(position);
		holder.channel_name.setText(channel.getTitle());

		return convertView;
	}

	class ViewHolder {
		TextView channel_name;
	}

}
